home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <memory.h>
- #include <process.h>
- #include <graph.h>
- #define CONTROL 0x34
- #define CONT2 0xb4
- int inport,integrate,data[512],datum;
- unsigned prt0,cntrlpt,prt1,prt2;
- int prime,count,i,iter,y[50],baseio,seg320;
- char name[20],buffer[24];
- float summa;
- main(argc,argv)
- int argc;
- char *argv[];
- {
- int k,value,rosso;
- unsigned div;
- long count,bkc;
- float trate,osc,rate;
- baseio=0x300;
- osc = 6.25;
- osc = osc * 1.0e6;
- cntrlpt = baseio + 7;
- prt0 = baseio + 4;
- prt2 = baseio + 6;
- bkc=1;
- rosso=4;
- inp(cntrlpt); /* halt */
- spawnl(P_WAIT,"intel",argv[0],"gather","d000","300","0",NULL);
- clark:
- cls();
- printf("\n A R G U S Project\n");
- printf(" code by Dr.Alberto E. Zagni\n");
- printf("\n ");
- printf("\n Input desired integration in sec. ");
- scanf( "%d",&integrate);
- rate=100;
- integrate=integrate*rate;
- /* count gives you the oscillator "divisor" just as in SIO's */
- count = osc/rate;
- if ( count < 2 ) count += 1;
- trate = osc /(float)count;
- printf("\nRate = %f ",trate);
- /* set timers for desired sampling rate */
- control_timer(count,osc,&trate);
- seg320=0xD000;
- inp(cntrlpt); /* halt 320 */
- printf("\nHit any character when ready");
- /* routine to check for a keyboard strike and to eat that char */
- ci();
- _setvideomode(_HRES16COLOR);
- _setbkcolor(bkc);
- _setcolor(rosso);
- k=1;
- _moveto(1,179);
- inp(prt2); /* go 320 */
- while ( !kbhit() ) { /* read k points */
-
- fulbuf(baseio); /* read in data from 320 */
- data[k]=datum;
- _lineto(k,180-(data[k]-90)*3);
- _settextposition(1,70);
- printf("%d ",data[k]);
- k+=1;
- if (k==618) k=1;
- }
-
- inp(cntrlpt); /* halt 320 */
- _setvideomode(_TEXTC80);
- exit(0);
- } /* END of program */
-
-
- control_timer(cnt,osc,trate)
- long cnt;
- float *trate,osc;
- {
- int ctl,cth;
- /* tell board timer info coming */
- outp(cntrlpt ,CONTROL);
- /* count is timing divisor */
- ctl = cnt & 0xff; /* lo byte */
- cth = ( cnt >> 8 ) & 0xff;/* hi byte */
- /* control timer 0 */
- outp(prt0 , ctl);
- outp(prt0 , cth);
- /* control timer 2 */
- outp(cntrlpt , CONT2);
- outp(prt2 , ctl);
- outp(prt2 , cth);
- /* compute new sampling rate for output on screen*/
- *trate = osc/(float)cnt;
- }
-
- ci()
- {
- int kbhit(),getch(),j;
- while (kbhit()==0) {};
- j=getch();
- }
- cls()
- {
- printf("\x1B[2J");
- }
- fulbuf(baseio)
- int baseio;
- {
- int i,j,porti;
- j=-1;
- summa=0;
- porti=baseio+4;
- for(i=0;i<integrate;i++) {
- while(inp(baseio+4)==j) {};
- j=inp(porti);
- summa+=abs((inp(baseio+1)<<8)+inp(baseio)-2048);
-
- }
- datum=summa/integrate;
- }
-